//书写品牌管理模块接口
import request from '@/utils/request'
import type { TWriterListResponseData, TWriter } from './type'
enum API {
  //获取已有品牌接口
  URL_WRITER_LIST = 'v1/m/author/allAuthors',
  // //添加品牌
  URL_WRITER_ADD = '/v1/m/author',
  URL_WRITER_UPDATE = '/v1/m/author/',

  //删除已有品牌
  URL_WRITER_DELETE = '/v1/m/author/',
}

export const reqWriterList = (
  pageNum: number,
  pageSize: number,
  nickName: string,
) =>
  request.get<any, TWriterListResponseData>(
    API.URL_WRITER_LIST +
      `?page=${pageNum}&limit=${pageSize}&nickName=${nickName}`,
  )
// //添加与修改已有品牌接口方法
export const reqAddOrUpdateWriter = (data: TWriter) => {
  if (data.authorId) {
    return request.put<any, any>(API.URL_WRITER_UPDATE + data.authorId, data)
  } else {
    return request.post<any, any>(API.URL_WRITER_ADD, data)
  }
}

// //删除某一个已有品牌的数据
export const reqDeleteWriter = (id: string) =>
  request.delete<any, any>(API.URL_WRITER_DELETE + id)
